<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>修改页面</title>
</head>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>

<form action="/update.do" method="post">
    <%--隐藏域 id --%>
    <input type="hidden" name="id" value="${product.id}">
    <table class="table table-striped table-bordered table-hover table-center table-condensed">
        <tr>
            <td>手机名称：</td>
            <td><input type="text" name="name" value="${product.name}"></td>
        </tr>
        <tr>
            <td>手机价格：</td>
            <td><input type="text" name="price" value="${product.price}"></td>
        </tr>
        <tr>
            <td>生产日期：</td>
            <td><input type="date" name="date" value="<fmt:formatDate value='${product.date}' pattern='yyyy-MM-dd'/>"></td>
        </tr>
        <tr>
            <td>热卖：</td>
            <td>
                <input type="radio" name="isHot" value="1" <c:if test="${product.isHot==1}">checked</c:if>>是
                <input type="radio" name="isHot" value="0" <c:if test="${product.isHot==0}">checked</c:if>>否
            </td>
        </tr>
        <tr>
            <td>商品描述：</td>
            <td>
                <textarea cols="25px" rows="8px" name="description">${product.description}</textarea>
            </td>
        </tr>
        <tr>
            <td>品牌：</td>
            <td>
               <%-- <select name="typeid">
                    <c:forEach items="${types}" var="type">
                        <option value="${type.tid}">${type.tname}</option>
                    </c:forEach>
                </select>--%>
                   <select name="typeid">
                       <%--获得tyeps表的数据展示--%>
                       <c:forEach items="${types}" var="type">
                           <option value="${type.tid}"
                               <%--type表的主键tid等于product的外键typeid--%>
                                   <c:if test="${type.tid==product.typeid}">
                                       selected
                                   </c:if>
                           >${type.tname}
                           </option>
                       </c:forEach>
                   </select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit"value="修改">
                <input type="reset" value="重置">
                <input type="button" value="返回" onclick="window.history.back()">
            </td>
        </tr>

    </table>

</form>
</body>
</html>
